<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>积分商城-{eyou:global name='web_name' /}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
    {eyou:static file="users/skin/css/basic.css" /}
    {eyou:static file="users/skin/css/eyoucms.css" /}
    <!-- 新样式 2020-11-25 -->
    {eyou:static file="users/skin/css/element/index.css" /}
    {eyou:static file="users/skin/css/e-user.css" /}
    {eyou:include file="users/skin/css/diy_css.htm" /}

    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="users/skin/js/bootstrap.min.js"/}
    {eyou:static file="users/skin/js/global.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
</head>

<body class="centre">
<!-- 头部 -->
{eyou:include file="users/users_header.htm" /}
<!-- 头部结束 -->

<div class="ey-body-bg">
    <div class="ey-body">
        <div class="ey-container w1200">
            <!-- 侧边 -->
            {eyou:include file="users/users_left.htm" /}
            <!-- 侧边结束 -->
            <!-- 中部 -->
            <div class="ey-con fr">
                <div class="el-main main-bg">
                    <div class="column-title mb20">
                        <div class="column-name">积分商城</div>
                    </div>
                    <div class="gift-user-info white-bg">
                        <div class="gift-user-text fl">
                            <div class="gift-user-infos">
                               <!-- <span class="z_yw_namepic">
                                    <img src="{$users.head_pic}">
                                </span>
                                <span>{$users.nickname}</span> -->
                                <span>
                                    您当前可兑换积分值：<b>{$users.scores}</b>积分
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="pro-list">
                        <div class="module-headline ">全部商品</div>
                        <ul>
                            {eyou:volist name="$list" id="vo" key="k"}
                            <li>
                                <div class="diva">
                                    <div class="tit">
                                        <div class="tit-l ico-hymb fl" style="cursor: pointer;"
                                             data-url="{:url('user/Memgift/users_gift_detail',['gift_id'=>$vo.gift_id])}"
                                             onclick="goDetail(this)">
                                            <img src="{$vo.litpic}">
                                        </div>
                                        <div class="tit-r fl">
                                            <h2 style="cursor: pointer;"
                                                data-url="{:url('user/Memgift/users_gift_detail',['gift_id'=>$vo.gift_id])}"
                                                onclick="goDetail(this)">{$vo.giftname}</h2>
                                            <p>{$vo.score}{$score_name}</p>
                                            {eyou:if condition='$users.scores >= $vo.score'}
                                            <p>
                                                {eq name='$vo.type' value='-1'}
                                                <a href="javascript:void(0)" class="okgo" data-url="{:url('user/Memgift/users_gift_shiwu',['gift_id'=>$vo.gift_id])}" onclick="jumpInfo(this)">立即兑换</a>
                                                {else/}
                                                <a href="javascript:void(0)" class="okgo" data-url="{:url('user/Memgift/users_gift_vip',['gift_id'=>$vo.gift_id])}" onclick="jumpVip(this)">立即兑换</a>
                                                {/eq}
                                            </p>
                                            {eyou:else /}
                                            <p><a class="okgo nones">{$score_name}不足</a></p>
                                            {/eyou:if}
                                        </div>
                                    </div>
                                </div>
                            </li>
                            {/eyou:volist}
                        </ul>
                    </div>
                    <div class="" style="border-top: 1px solid #efefef;padding: 20px 0;">
                        <div class="container-box-n" style="padding-bottom: 20px;">
                            <div class="title_z"><a class="current">兑换记录</a></div>
                            <div class="form-box">
                                {eyou:empty name="$order_list"}
                                <div class="ey-table-body ey-table">
                                    <table>
                                        <thead class="ey-table-thead">
                                        <tr>
                                            <th style="width: 80px; text-align: center;"><span>ID</span></th>
                                            <th><span>商品名称</span></th>
                                            <th style="width: 10%;"><span>消耗({$score_name})</span></th>
                                            <th style="width: 10%;"><span>兑换时间</span></th>
                                            <th style="width: 10%;"><span>状态</span></th>
                                        </tr>
                                        </thead>
                                    </table>
                                    <div class="no_row" style="margin-top: 50px; min-height: 150px;">
                                        <div class="no_pic"><img src="__PUBLIC__/static/common/images/null-data.png">
                                        </div>
                                    </div>
                                </div>
                                {eyou:else/}
                                <div class="ey-table-body ey-table">
                                    <table>
                                        <thead class="ey-table-thead">
                                        <tr>
                                            <th style="width: 80px; text-align: center;"><span>ID</span></th>
                                            <th><span>商品名称</span></th>
                                            <th style="width: 15%;"><span>消耗({$score_name})</span></th>
                                            <th style="width: 20%;"><span>兑换时间</span></th>
                                            <th style="width: 10%;"><span>状态</span> </th>
                                        </tr>
                                        </thead>
                                        <tbody class="ey-table-tbody">
                                        {eyou:volist name="$order_list" id="vo" }
                                        <tr>
                                            <td style="width: 80px; text-align: center;">{$vo.key}</td>
                                            <td>
                                                <span style="display: inline-block;width: 26px;height: 26px;margin-right: 8px;"><img src="{$vo.litpic}" style="width: 100%; height: 100%; "></span>{$vo.giftname}<span class="gift-help-tip"><i class="u_iconfont icon-gantanhao-quan" style="font-size: 14px;"></i></span>
                                            </td>
                                            <td style="width: 15%;">{$vo.score}{eyou:if condition="$vo.status eq 2"}[已返还]{/eyou:if}</td>
                                            <td style="width: 15%;">{$vo.add_time|MyDate="Y-m-d H:i",###}</td>
                                            <td style="width: 10%;">
                                                {eyou:if condition="$vo.status eq 1"}
                                                <span style="color: #67c23a">已发货</span>
                                                {elseif condition="$vo.status eq 2"}
                                                <span style="color: #F00">发货取消</span>
                                                {else /}
                                                <span style="color: #333">待发货</span>
                                                {/eyou:if}
                                            </td>

                                        </tr>
                                        {/eyou:volist}
                                        </tbody>
                                    </table>
                                </div>
                                {/eyou:empty}
                            </div>
                            <div>{$page}</div>
                        </div>
                    </div>


                </div>
            </div>
            <!-- 中部结束 -->
        </div>
    </div>
</div>
<script>
    //兑换实物
    function jumpInfo(obj){
        var url = $(obj).data('url');
        var index = layer.open({
            type: 2,
            id: 'iframe_goinfo',
            title: '填写快递信息',
            fixed: true, //不固定
            shadeClose: false,
            shade: [0.3,'#000'],
            maxmin: false, //开启最大化最小化按钮
            closeBtn: 1,
            area: ['388px','288px'],
            content: url
        });
    }
    //打开详情页
    function goDetail(obj) {
        //iframe窗
        var url = $(obj).data('url');
        var index = layer.open({
            type: 2,
            id: 'iframe_goDetail',
            title: '商品详情',
            fixed: true, //不固定
            shadeClose: false,
            shade: [0.3, '#000'],
            maxmin: false, //开启最大化最小化按钮
            closeBtn: 1,
            area: ['700px', '99%'],
            content: url,
        });
    }
    //兑换会员
    function jumpVip(obj) {
        var url = $(obj).data('url');
        layer.confirm('确定要兑换商品？', {
            title: false,
            closeBtn: false
        }, function() {
            $.ajax({
                url: url,
                type: 'POST',
                dataType: 'JSON',
                data: {
                    long: 0
                },
                success: function(res) {
                    if (1 == res.code) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            window.location.reload();
                        });
                    } else if (res.code == 2) {
                        layer.confirm(res.msg, {
                            btn: ['继续兑换', '取消'] //按钮
                        }, function() {
                            $.ajax({
                                url: url,
                                type: 'POST',
                                dataType: 'JSON',
                                data: {
                                    long: 1
                                },
                                success: function(res) {
                                    if (1 == res.code) {
                                        layer.msg(res.msg, {
                                            icon: 1,
                                            time: 1000
                                        }, function() {
                                            window.location.reload();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2,
                                            time: 2000
                                        });
                                    }
                                },
                                error: function(e) {
                                    layer.closeAll();
                                    layer.alert(e.responseText, {
                                        icon: 5,
                                        title: false
                                    });
                                }
                            })
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000
                        });
                    }
                },
                error: function(e) {
                    layer.closeAll();
                    layer.alert(e.responseText, {
                        icon: 5,
                        title: false
                    });
                }
            })
        }, function(index) {
            layer.closeAll(index);
        });
    }
</script>
{eyou:include file="users/users_footer.htm" /}